<template>
  <div class="department">
    <page-search
      :searchFormConfig="searchFormConfig"
      @resetBtnClick="handleResetClick"
      @searchBtnClick="handleSearchClick"
    ></page-search>
    <page-content
      ref="pageContentRef"
      pageName="department"
      :contentTableConfig="contentTableConfig"
      @newBtnClick="handleNewData"
      @editBtnClick="handleEditData"
    ></page-content>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import PageContent from '@/components/page-content'
import { contentTableConfig } from './config/content.config'
import PageSearch from '@/components/page-search'
import { searchFormConfig } from './config/search.config'
import { usePageSearch } from '@/hooks/use-page-search'
import { modalConfig } from './config/modal.config'
import { usePageModal } from '@/hooks/use-page-modal'

export default defineComponent({
  name: 'department',
  components: {
    PageContent,
    PageSearch
  },
  setup() {
    const [pageContentRef, handleResetClick, handleSearchClick] = usePageSearch()
    // pageModal相关的hooks
    const newCallback = () => {
      const res = modalConfig.formItems.find((item) => item.field === 'password')
      console.log(res, 123)
      // modalConfig.formItems.find((item) => item.field === 'password')!.isHidden = false
    }
    const editCallback = () => {
      // modalConfig.formItems.find((item) => item.field === 'password')!.isHidden = true
    }
    const [handleNewData, handleEditData, pageModalRef, defaultInfo] = usePageModal(
      newCallback,
      editCallback
    )
    return {
      searchFormConfig,
      contentTableConfig,
      pageContentRef,
      handleResetClick,
      handleSearchClick,
      handleNewData,
      handleEditData,
      pageModalRef,
      defaultInfo
    }
  }
})
</script>

<style scoped></style>
